package com.asm.service.impl;

import com.asm.mapper.Snv2SEMapper;
import com.asm.pojo.Snv2SE;
import com.asm.service.Snv2SEService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;

@Service
public class Snv2SEServiceImpl implements Snv2SEService {
    @Autowired
    private Snv2SEMapper snv2SEMapper;

    @Override
    public List<Snv2SE> getDetailSuperEnhancerBySnv(String snv) {
        List<String> tables = getTable(snv);
        List<Snv2SE> result = tables.stream()
                .map(table -> snv2SEMapper.getDetailSuperEnhancerBySnv(snv, table))
                .flatMap(Collection::stream)
                .collect(Collectors.toList());
        return result;
    }

    public List<String> getTable(String snv){
        List<String> list = snv2SEMapper.getTable(snv);
        List<String> tables = list.stream()
                .map(s -> "detail_cis_se_" + s)
                .collect(Collectors.toList());
        return tables;
    }
}
